import request from '@/router/axios';
//所有启动中项目下拉选
export const getProjects = (params) => {
  return request({
    url: '/api/hg-public/projectinfo/findAll',
    method: 'get',
    params: {
      ...params
    }
  })
}

//所有项目下拉选
export const getProjectList = (params) => {
  return request({
    url: '/api/hg-public/projectinfo/list',
    method: 'get',
    params: {
      ...params
    }
  })
} 
//所有进行中的项目下拉选
export const getOngoingProjects = (params) => {
  return request({
    url: '/api/hg-public/prodplanlist/getProjects',
    method: 'get',
    params: {
      ...params
    }
  })
}

//项目产品信息
//列表
export const getProductList = (params) => {
  return request({
    url: '/api/hg-public/projectprdinfo/list',
    method: 'get',
    params: {
      ...params
    }
  })
}
// 产品信息
export const getProducts = (params) => {
  return request({
    url: '/api/hg-public/projectprdinfo/listByProject',
    method: 'get',
    params: {
      ...params
    }
  })
}
// 获取项目下的直接上级产品
export const getDirProductList = (params) => {
  return request({
    url: '/api/hg-public/projectprdinfo/prjleaderprdlist',
    method: 'get',
    params: {
      ...params
    }
  })
}
//根据产品名称模糊查询产品下拉选
export const searchProduct = (materialName) => {
  return request({
    url: '/api/hg-public/prdinfo/list',
    method: 'get',
    params: {
      materialName,
    }
  })
}
//新增项目产品信息
export const addProduct = (row) => {
  return request({
    url: '/api/hg-public/projectprdinfo/save',
    method: 'post',
    data: row
  })
}

//删除项目产品信息
export const removeProduct = (ids) => {
  return request({
    url: '/api/hg-public/projectprdinfo/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}

//更新项目产品信息
export const updateProduct = (row) => {
  return request({
    url: '/api/hg-public/projectprdinfo/update',
    method: 'post',
    data: row
  })
}

//获取产品信息详情
export const getProduct = (id) => {
  return request({
    url: '/api/hg-public/projectprdinfo/detail',
    method: 'get',
    params: {
      id,
    }
  })
}

//根据直接上级、每套用量计算年需求量
export const getYearNeed = (params) => {
  return request({
    url: '/api/hg-public/projectprdinfo/getyearneeds',
    method: 'get',
    params: {
      ...params
    }
  })
}

//根据产品图号和上级产品图号获取每套用量和年需求量
export const getQuotaYearNeed = (params) => {
  return request({
    url: '/api/hg-public/prdbom/getprdquota',
    method: 'get',
    params: {
      ...params
    }
  })
}
//根据产品图号查询产品Bom
export const searchBomDetail = (params) => {
  return request({
    url: '/api/hg-public/prdinfo/detailwithbom',
    method: 'get',
    params: {
      ...params
    }
  })
}

//产品BOM
//产品Bom列表
export const getBomList = (params) => {
  return request({
    url: '/api/hg-public/prdbom/bomTreeByProjectId',
    method: 'get',
    params: {
      ...params
    }
  })
}
//根据项目获取产品下拉选 flag=1 类型为产品， flag=2 Bom顶级的 flag=3 类型为产品或自制件
export const getTopProductList = (params) => {
  return request({
    url: '/api/hg-public/projectprdinfo/topprdlist',
    method: 'get',
    params: {
      ...params
    }
  })
}
//新增Bom 辅助材料
export const addBomfzcl = (row) => {
  return request({
    url: '/api/hg-public/prdbom/savefzcl',
    method: 'post',
    data: row
  })
}
//详情Bom 辅助材料
export const getBomfzcl = (id) => {
  return request({
    url: '/api/hg-public/prdbom/detail',
    method: 'get',
    params: {
      id,
    }
  })
}
//编辑Bom 辅助材料
export const updateBomfzcl = (row) => {
  return request({
    url: '/api/hg-public/prdbom/update',
    method: 'post',
    data: row
  })
}
//删除Bom 辅助材料
export const removeBomfzcl = (ids) => {
  return request({
    url: '/api/hg-public/prdbom/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}

//客户产品需求 
//客户产品需求列表
export const getDemandList = (params) => {
  return request({
    url: '/api/hg-public/custprddemandinfo/list',
    method: 'get',
    params: {
      ...params,
    }
  })
}

//获取客户产品需求重要时间节点
export const getDemandTimenodes = (id) => {
  return request({
    url: '/api/hg-public/custprddemandinfo/timenodes',
    method: 'get',
    params: {
      id,
    }
  })
}
//获取客户产品需求客户产品要求列表
export const getDemandRequire = (id) => {
  return request({
    url: '/api/hg-public/custprddemandinfo/requirements',
    method: 'get',
    params: {
      id,
    }
  })
}



//项目开发任务书
//项目开发任务书列表
export const getTaskList = (params) => {
  return request({
    url: '/api/hg-public/projectTask/list',
    method: 'get',
    params: {
      ...params,
    }
  })
}
//新增项目开发任务书
export const addTask = (row) => {
  return request({
    url: '/api/hg-public/projectTask/save',
    method: 'post',
    data: row
  })
}

//删除项目开发任务书
export const removeTask = (ids) => {
  return request({
    url: '/api/hg-public/projectTask/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}

//更新项目开发任务书
export const updateTask = (row) => {
  return request({
    url: '/api/hg-public/projectTask/update',
    method: 'post',
    data: row
  })
}

//获取项目开发任务书详情
export const getTask = (id) => {
  return request({
    url: '/api/hg-public/projectTask/detail',
    method: 'get',
    params: {
      id,
    }
  })
}


//人员需求清单 
//人员需求清单列表
export const getMemberList = (params) => {
  return request({
    url: '/api/hg-public/personrequirelist/list',
    method: 'get',
    params: {
      ...params,
    }
  })
}
//新增人员需求清单
export const addMember = (row) => {
  return request({
    url: '/api/hg-public/personrequirelist/save',
    method: 'post',
    data: row
  })
}

//删除人员需求清单
export const removeMember = (projectNo, productDrawingNo) => {
  return request({
    url: '/api/hg-public/personrequirelist/remove',
    method: 'post',
    params: {
      projectNo, productDrawingNo
    }
  })
}

//更新人员需求清单
export const updateMember = (row) => {
  return request({
    url: '/api/hg-public/personrequirelist/update',
    method: 'post',
    data: row
  })
}

//获取人员需求清单详情
export const getMemberDetails = (projectNo, productDrawingNo) => {
  return request({
    url: '/api/hg-public/personrequirelist/detail',
    method: 'get',
    params: {
      projectNo, productDrawingNo,
    }
  })
}

//获取工序详情
export const getMemberDetailList = (productId) => {
  return request({
    url: '/api/hg-public/personrequirelist/getPersonRequireList',
    method: 'get',
    params: {
      productId,
    }
  })
}

